diff options
| author | Jeff Epler <jepler@gmail.com> | 2025-05-09 22:04:29 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-05-16 11:52:03 +1000 |
| commit | 8648e6d1cf19afec1485ed204b2135ca322c6a8b (patch) | |
| tree | a6ac5a5f705f70384e879053d39431fca2ddd1c4 /tests | |
| parent | 605eda158de4f40ba03e15fa183a178f7cf1a1da (diff) | |
tests/cpydiff: Add test of underscore-in-literals.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cpydiff/syntax_literal_underscore.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/cpydiff/syntax_literal_underscore.py b/tests/cpydiff/syntax_literal_underscore.py new file mode 100644 index 000000000..4b1406e9f --- /dev/null +++ b/tests/cpydiff/syntax_literal_underscore.py @@ -0,0 +1,19 @@ +""" +categories: Syntax,Literals +description: MicroPython accepts underscores in numeric literals where CPython doesn't +cause: Different parser implementation + +MicroPython's tokenizer ignores underscores in numeric literals, while CPython +rejects multiple consecutive underscores and underscores after the last digit. + +workaround: Remove the underscores not accepted by CPython. +""" + +try: + print(eval("1__1")) +except SyntaxError: + print("Should not work") +try: + print(eval("1_")) +except SyntaxError: + print("Should not work") |
