summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-10 20:38:57 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-11 01:00:21 +0200
commit899c69f94c4a776a41c66129a93c4db52535d73d (patch)
tree527eb1401c59eaacde1346fab0f9d34cd8ba3a63 /tests
parentbab5cfb34f6b1ed4b16c24221479c20f5ed71c4f (diff)
downloadmicropython-899c69f94c4a776a41c66129a93c4db52535d73d.tar.gz
micropython-899c69f94c4a776a41c66129a93c4db52535d73d.zip
compile_for_stmt_optimised_range(): Properly handle negative & unknown steps.
If step is not constant, in first approximation, we can't apply optimization, (well, we could, but need a special case for this).
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/tests/for1.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/basics/tests/for1.py b/tests/basics/tests/for1.py
index 5a2635638d..c6199416cd 100644
--- a/tests/basics/tests/for1.py
+++ b/tests/basics/tests/for1.py
@@ -7,3 +7,13 @@ def f():
print(x, y, z)
f()
+
+# range with negative step
+for i in range(3, -1, -1):
+ print(i)
+
+a = -1
+# range with non-constant step - we optimize constant steps, so this
+# will be executed differently
+for i in range(3, -1, a):
+ print(i)