summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-09-13 22:30:24 +1000
committerDamien George <damien@micropython.org>2021-09-13 22:30:24 +1000
commit426785a19eeb12aef7383fbda4693575d8c4dddf (patch)
tree36dcbf57be41384ccaab8570043b465a3632201b /tests
parentc0761d28fc46072d73daf6bdd1c6abbbac0fc9c1 (diff)
py/emitnative: Ensure load_subscr does not clobber existing REG_RET.
Fixes issue #7782, and part of issue #6314. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/micropython/viper_subscr_multi.py20
-rw-r--r--tests/micropython/viper_subscr_multi.py.exp2
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/micropython/viper_subscr_multi.py b/tests/micropython/viper_subscr_multi.py
new file mode 100644
index 000000000..1561e5534
--- /dev/null
+++ b/tests/micropython/viper_subscr_multi.py
@@ -0,0 +1,20 @@
+# test viper with multiple subscripts in a single expression
+
+
+@micropython.viper
+def f1(b: ptr8):
+ b[0] += b[1]
+
+
+@micropython.viper
+def f2(b: ptr8, i: int):
+ b[0] += b[i]
+
+
+b = bytearray(b"\x01\x02")
+f1(b)
+print(b)
+
+b = bytearray(b"\x01\x02")
+f2(b, 1)
+print(b)
diff --git a/tests/micropython/viper_subscr_multi.py.exp b/tests/micropython/viper_subscr_multi.py.exp
new file mode 100644
index 000000000..a2c298bb1
--- /dev/null
+++ b/tests/micropython/viper_subscr_multi.py.exp
@@ -0,0 +1,2 @@
+bytearray(b'\x03\x02')
+bytearray(b'\x03\x02')