summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tcl.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_tcl.py')
-rw-r--r--Lib/test/test_tcl.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index 443787d..d479f7d 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -73,6 +73,18 @@ class TclTest(unittest.TestCase):
tcl.call('set','a','1')
self.assertEqual(tcl.call('set','a'),'1')
+ def test_call_passing_null(self):
+ tcl = self.interp
+ tcl.call('set', 'a', 'a\0b') # ASCII-only
+ self.assertEqual(tcl.getvar('a'), 'a\x00b')
+ self.assertEqual(tcl.call('set', 'a'), 'a\x00b')
+ self.assertEqual(tcl.eval('set a'), 'a\x00b')
+
+ tcl.call('set', 'a', '\u20ac\0') # non-ASCII
+ self.assertEqual(tcl.getvar('a'), '\u20ac\x00')
+ self.assertEqual(tcl.call('set', 'a'), '\u20ac\x00')
+ self.assertEqual(tcl.eval('set a'), '\u20ac\x00')
+
def testCallException(self):
tcl = self.interp
self.assertRaises(TclError,tcl.call,'set','a')
@@ -98,6 +110,18 @@ class TclTest(unittest.TestCase):
tcl.setvar('a','1')
self.assertEqual(tcl.eval('set a'),'1')
+ def test_setvar_passing_null(self):
+ tcl = self.interp
+ tcl.setvar('a', 'a\0b') # ASCII-only
+ self.assertEqual(tcl.getvar('a'), 'a\x00b')
+ self.assertEqual(tcl.call('set', 'a'), 'a\x00b')
+ self.assertEqual(tcl.eval('set a'), 'a\x00b')
+
+ tcl.setvar('a', '\u20ac\0') # non-ASCII
+ self.assertEqual(tcl.getvar('a'), '\u20ac\x00')
+ self.assertEqual(tcl.call('set', 'a'), '\u20ac\x00')
+ self.assertEqual(tcl.eval('set a'), '\u20ac\x00')
+
def testSetVarArray(self):
tcl = self.interp
tcl.setvar('a(1)','1')