diff options
author | Nevada Sanchez <me@nevadasanchez.com> | 2017-04-13 17:32:54 (GMT) |
---|---|---|
committer | Mariatta <Mariatta@users.noreply.github.com> | 2017-04-13 17:32:54 (GMT) |
commit | a6e395dffadf8c5124903c01ad69fefa36b1a935 (patch) | |
tree | 82fc605d0a1b44e9442a735f37771c4b4cfb3c86 /Lib/lib2to3/tests | |
parent | 873ef20d0007b4b120933473e6252d2309a70102 (diff) | |
download | cpython-a6e395dffadf8c5124903c01ad69fefa36b1a935.zip cpython-a6e395dffadf8c5124903c01ad69fefa36b1a935.tar.gz cpython-a6e395dffadf8c5124903c01ad69fefa36b1a935.tar.bz2 |
bpo-29869: Allow underscores in numeric literals in lib2to3. (GH-1119)
* Allow underscores in numeric literals in lib2to3.
* Stricter literal parsing for Python 3.6 in lib2to3.pgen2.tokenize.
* Add test case for underscores in literals in Python 3.
Diffstat (limited to 'Lib/lib2to3/tests')
-rw-r--r-- | Lib/lib2to3/tests/data/py3_test_grammar.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/lib2to3/tests/data/py3_test_grammar.py b/Lib/lib2to3/tests/data/py3_test_grammar.py index cf31a54..0b9bee0 100644 --- a/Lib/lib2to3/tests/data/py3_test_grammar.py +++ b/Lib/lib2to3/tests/data/py3_test_grammar.py @@ -72,6 +72,28 @@ class TokenTests(unittest.TestCase): x = 0b100000000000000000000000000000000000000000000000000000000000000000000 x = 0B111111111111111111111111111111111111111111111111111111111111111111111 + def testUnderscoresInNumbers(self): + # Integers + x = 1_0 + x = 123_456_7_89 + x = 0xabc_123_4_5 + x = 0X_abc_123 + x = 0B11_01 + x = 0b_11_01 + x = 0o45_67 + x = 0O_45_67 + + # Floats + x = 3_1.4 + x = 03_1.4 + x = 3_1. + x = .3_1 + x = 3.1_4 + x = 0_3.1_4 + x = 3e1_4 + x = 3_1e+4_1 + x = 3_1E-4_1 + def testFloats(self): x = 3.14 x = 314. |