mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
tests/cpydiff: Add test of underscore-in-literals.
Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
committed by
Damien George
parent
605eda158d
commit
8648e6d1cf
19
tests/cpydiff/syntax_literal_underscore.py
Normal file
19
tests/cpydiff/syntax_literal_underscore.py
Normal file
@@ -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")
|
||||
Reference in New Issue
Block a user