summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-12-08 21:05:14 +0000
committerDamien George <damien.p.george@gmail.com>2015-12-08 21:05:14 +0000
commit33ac0fd09f15377f571c3d2455802cf7a8ac09a8 (patch)
tree48ed1a0c11a2fdc8c2256b5f42a6b38eede9301b /tests/basics
parentbbe2e22fcb3bf83b03ad25856e29995987e1fc40 (diff)
downloadmicropython-33ac0fd09f15377f571c3d2455802cf7a8ac09a8.tar.gz
micropython-33ac0fd09f15377f571c3d2455802cf7a8ac09a8.zip
py: Don't try to optimise for+range when args are not simple expressions.
Addresses issue #1693.
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/for_range.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/basics/for_range.py b/tests/basics/for_range.py
new file mode 100644
index 0000000000..ddff5ebd44
--- /dev/null
+++ b/tests/basics/for_range.py
@@ -0,0 +1,58 @@
+# test for+range, mostly to check optimisation of this pair
+
+# apply args using *
+for x in range(*(1, 3)):
+ print(x)
+for x in range(1, *(6, 2)):
+ print(x)
+
+# apply args using **
+try:
+ for x in range(**{'end':1}):
+ print(x)
+except TypeError:
+ print('TypeError')
+try:
+ for x in range(0, **{'end':1}):
+ print(x)
+except TypeError:
+ print('TypeError')
+try:
+ for x in range(0, 1, **{'step':1}):
+ print(x)
+except TypeError:
+ print('TypeError')
+
+# keyword args
+try:
+ for x in range(end=1):
+ print(x)
+except TypeError:
+ print('TypeError')
+try:
+ for x in range(0, end=1):
+ print(x)
+except TypeError:
+ print('TypeError')
+try:
+ for x in range(0, 1, step=1):
+ print(x)
+except TypeError:
+ print('TypeError')
+
+# argument is a comprehension
+try:
+ for x in range(0 for i in []):
+ print(x)
+except TypeError:
+ print('TypeError')
+try:
+ for x in range(0, (0 for i in [])):
+ print(x)
+except TypeError:
+ print('TypeError')
+try:
+ for x in range(0, 1, (0 for i in [])):
+ print(x)
+except TypeError:
+ print('TypeError')