aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George2014-05-08 15:58:39 +0000
committerDamien George2014-05-08 15:58:39 +0000
commitffae48d7507d398806bd935b054b7ca19bc01161 (patch)
tree0b21d74a0decf3167f3a92e7df6cd2fb21130eea /tests
parentc1c32d65af038ba1b2a2a8dd69e3f7e63eac5f3e (diff)
py, compiler: Add basic support for A=const(123).
You can now do: X = const(123) Y = const(456 + X) and the compiler will replace X and Y with their values. See discussion in issue #266 and issue #573.
Diffstat (limited to 'tests')
-rw-r--r--tests/micropython/const.py11
-rw-r--r--tests/micropython/const.py.exp2
-rwxr-xr-xtests/run-tests2
3 files changed, 14 insertions, 1 deletions
diff --git a/tests/micropython/const.py b/tests/micropython/const.py
new file mode 100644
index 000000000..457365c50
--- /dev/null
+++ b/tests/micropython/const.py
@@ -0,0 +1,11 @@
+# test constant optimisation
+
+X = const(123)
+Y = const(X + 456)
+
+print(X, Y + 1)
+
+def f():
+ print(X, Y + 1)
+
+f()
diff --git a/tests/micropython/const.py.exp b/tests/micropython/const.py.exp
new file mode 100644
index 000000000..c447aaf8c
--- /dev/null
+++ b/tests/micropython/const.py.exp
@@ -0,0 +1,2 @@
+123 580
+123 580
diff --git a/tests/run-tests b/tests/run-tests
index 618d11831..9e837c3cb 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -112,7 +112,7 @@ def main():
if len(args.files) == 0:
if pyb is None:
# run PC tests
- test_dirs = ('basics', 'float', 'import', 'io', 'misc')
+ test_dirs = ('basics', 'micropython', 'float', 'import', 'io', 'misc')
else:
# run pyboard tests
test_dirs = ('basics', 'float', 'pyb', 'pybnative', 'inlineasm')