summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-06-07 19:36:39 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-06-07 19:36:39 (GMT)
commitc41616230211822e838634b84b445f8a124add08 (patch)
treee6b7fdd58675a3e0e5957dea0ad159168c5371db /Lib/test/test_grammar.py
parent024b2f52bf76358eea62f0206ea32c1ca518fde3 (diff)
downloadcpython-c41616230211822e838634b84b445f8a124add08.zip
cpython-c41616230211822e838634b84b445f8a124add08.tar.gz
cpython-c41616230211822e838634b84b445f8a124add08.tar.bz2
allow the keyword else immediately after (no space) an integer (closes #21642)
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index bba8820..f012de1 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -80,6 +80,12 @@ class TokenTests(unittest.TestCase):
x = .3e14
x = 3.1e4
+ def test_float_exponent_tokenization(self):
+ # See issue 21642.
+ self.assertEqual(1 if 1else 0, 1)
+ self.assertEqual(1 if 0else 0, 0)
+ self.assertRaises(SyntaxError, eval, "0 if 1Else 0")
+
def test_string_literals(self):
x = ''; y = ""; self.assertTrue(len(x) == 0 and x == y)
x = '\''; y = "'"; self.assertTrue(len(x) == 1 and x == y and ord(x) == 39)