diff options
| author | Damien George | 2018-06-02 00:21:46 +1000 |
|---|---|---|
| committer | Damien George | 2018-06-12 12:17:43 +1000 |
| commit | 6a445b60fad87c94a1d00ce3a043b881a1f7a5a4 (patch) | |
| tree | 956f1b602023afae9231f6f03a38c997e3efc073 /tests | |
| parent | b2fa1b50edaea43007d692d24391c6f3aa4d15ca (diff) | |
py/lexer: Add support for underscores in numeric literals.
This is a very convenient feature introduced in Python 3.6 by PEP 515.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basics/python36.py | 10 | ||||
| -rw-r--r-- | tests/basics/python36.py.exp | 5 | ||||
| -rw-r--r-- | tests/float/python36.py | 10 | ||||
| -rw-r--r-- | tests/float/python36.py.exp | 5 |
4 files changed, 30 insertions, 0 deletions
diff --git a/tests/basics/python36.py b/tests/basics/python36.py new file mode 100644 index 000000000..20ecd9227 --- /dev/null +++ b/tests/basics/python36.py @@ -0,0 +1,10 @@ +# tests for things that only Python 3.6 supports + +# underscores in numeric literals +print(100_000) +print(0b1010_0101) +print(0xff_ff) + +# underscore supported by int constructor +print(int('1_2_3')) +print(int('0o1_2_3', 8)) diff --git a/tests/basics/python36.py.exp b/tests/basics/python36.py.exp new file mode 100644 index 000000000..4b65daafa --- /dev/null +++ b/tests/basics/python36.py.exp @@ -0,0 +1,5 @@ +100000 +165 +65535 +123 +83 diff --git a/tests/float/python36.py b/tests/float/python36.py new file mode 100644 index 000000000..6e8fb1f21 --- /dev/null +++ b/tests/float/python36.py @@ -0,0 +1,10 @@ +# tests for things that only Python 3.6 supports, needing floats + +# underscores in numeric literals +print(1_000.1_8) +print('%.2g' % 1e1_2) + +# underscore supported by int/float constructors +print(float('1_2_3')) +print(float('1_2_3.4')) +print('%.2g' % float('1e1_3')) diff --git a/tests/float/python36.py.exp b/tests/float/python36.py.exp new file mode 100644 index 000000000..3febfed9a --- /dev/null +++ b/tests/float/python36.py.exp @@ -0,0 +1,5 @@ +1000.18 +1e+12 +123.0 +123.4 +1e+13 |
