summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tcl.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-02 15:46:50 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-02 15:46:50 (GMT)
commitea134da9297b14bfa8dbf3a45149bc2df28c1eb9 (patch)
tree0637056758d2fd85b1bf8cf867fb84e02fceea45 /Lib/test/test_tcl.py
parent8e44aa5ae475be3e2944daee4d98ca36e466dd6a (diff)
downloadcpython-ea134da9297b14bfa8dbf3a45149bc2df28c1eb9.zip
cpython-ea134da9297b14bfa8dbf3a45149bc2df28c1eb9.tar.gz
cpython-ea134da9297b14bfa8dbf3a45149bc2df28c1eb9.tar.bz2
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/test/test_tcl.py')
-rw-r--r--Lib/test/test_tcl.py46
1 files changed, 39 insertions, 7 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index c9410a9..9b1a8d7 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -133,9 +133,22 @@ 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)
+ if tcl_version >= (8, 4): # wideInt was added in Tcl 8.4
+ integers += (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 +283,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 +315,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 +347,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 +388,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 +410,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 +442,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):
@@ -473,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,