aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George2014-05-07 23:27:45 +0100
committerDamien George2014-05-07 23:27:45 +0100
commitd509ac25f9f387c5690126c49893d3da142971c2 (patch)
tree73c188e7ae137e28740d28d42cfdcbc939cc4df4 /tests
parentbe6aa53cdb18359e5c7e51caac2ca0ea7160962d (diff)
py: Fix stack access in thumb native emitter.
Diffstat (limited to 'tests')
-rw-r--r--tests/pybnative/for.py15
-rw-r--r--tests/pybnative/for.py.exp8
-rw-r--r--tests/pybnative/while.py13
-rw-r--r--tests/pybnative/while.py.exp4
4 files changed, 32 insertions, 8 deletions
diff --git a/tests/pybnative/for.py b/tests/pybnative/for.py
new file mode 100644
index 000000000..309c6c14f
--- /dev/null
+++ b/tests/pybnative/for.py
@@ -0,0 +1,15 @@
+import pyb
+
+@micropython.native
+def f1(n):
+ for i in range(n):
+ print(i)
+
+f1(4)
+
+@micropython.native
+def f2(r):
+ for i in r:
+ print(i)
+
+f2(range(4))
diff --git a/tests/pybnative/for.py.exp b/tests/pybnative/for.py.exp
new file mode 100644
index 000000000..d4dc73eff
--- /dev/null
+++ b/tests/pybnative/for.py.exp
@@ -0,0 +1,8 @@
+0
+1
+2
+3
+0
+1
+2
+3
diff --git a/tests/pybnative/while.py b/tests/pybnative/while.py
index a3f64a800..3ea7221ea 100644
--- a/tests/pybnative/while.py
+++ b/tests/pybnative/while.py
@@ -1,14 +1,15 @@
+import pyb
+
@micropython.native
-def f(led, n):
+def f(led, n, d):
led.off()
i = 0
while i < n:
+ print(i)
led.toggle()
- d = pyb.delay
- d(50) # pyb.delay(50) doesn't work!
+ pyb.delay(d)
i += 1
- print(i)
led.off()
-f(pyb.LED(1), 2)
-f(pyb.LED(2), 4)
+f(pyb.LED(1), 2, 150)
+f(pyb.LED(2), 4, 50)
diff --git a/tests/pybnative/while.py.exp b/tests/pybnative/while.py.exp
index 5cd83db0f..d95e7f145 100644
--- a/tests/pybnative/while.py.exp
+++ b/tests/pybnative/while.py.exp
@@ -1,6 +1,6 @@
+0
1
-2
+0
1
2
3
-4