diff options
author | Damien George <damien.p.george@gmail.com> | 2016-09-27 13:34:21 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-09-27 13:34:21 +1000 |
commit | 791b65f4b261a23e427664f0b86ce32b60e33cb5 (patch) | |
tree | 87a8a76e78bb440977d437637e98c1e9f3aaaf1b /tests/micropython | |
parent | f65e4f0b8fbd3992da6cf8a69e89e3bad3001d36 (diff) |
py/modmicropython: Add micropython.const, alias for identity function.
Having a micropython.const identity function, and writing "from micropython
import const" at the start of scripts that use the const feature, allows to
write scripts which are compatible with CPython, and with uPy builds that
don't include const optimisation.
This patch adds such a function and updates the tests to do the import.
Diffstat (limited to 'tests/micropython')
-rw-r--r-- | tests/micropython/const.py | 2 | ||||
-rw-r--r-- | tests/micropython/const2.py | 2 | ||||
-rw-r--r-- | tests/micropython/const_error.py | 2 |
3 files changed, 6 insertions, 0 deletions
diff --git a/tests/micropython/const.py b/tests/micropython/const.py index 09717fd14..660a095f2 100644 --- a/tests/micropython/const.py +++ b/tests/micropython/const.py @@ -1,5 +1,7 @@ # test constant optimisation +from micropython import const + X = const(123) Y = const(X + 456) diff --git a/tests/micropython/const2.py b/tests/micropython/const2.py index fb4588435..60085a1e0 100644 --- a/tests/micropython/const2.py +++ b/tests/micropython/const2.py @@ -1,5 +1,7 @@ # check that consts are not replaced in anything except standalone identifiers +from micropython import const + X = const(1) Y = const(2) Z = const(3) diff --git a/tests/micropython/const_error.py b/tests/micropython/const_error.py index b46efcae2..6d3d135b5 100644 --- a/tests/micropython/const_error.py +++ b/tests/micropython/const_error.py @@ -1,5 +1,7 @@ # make sure syntax error works correctly for bad const definition +from micropython import const + def test_syntax(code): try: exec(code) |