2015-03-25 19:10:09 -04:00
|
|
|
# make sure syntax error works correctly for bad const definition
|
2015-03-01 07:06:24 -05:00
|
|
|
|
2016-09-26 23:34:21 -04:00
|
|
|
from micropython import const
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2015-03-25 19:10:09 -04:00
|
|
|
def test_syntax(code):
|
|
|
|
try:
|
|
|
|
exec(code)
|
|
|
|
except SyntaxError:
|
|
|
|
print("SyntaxError")
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2015-03-25 19:10:09 -04:00
|
|
|
# argument not a constant
|
|
|
|
test_syntax("a = const(x)")
|
|
|
|
|
|
|
|
# redefined constant
|
|
|
|
test_syntax("A = const(1); A = const(2)")
|