summaryrefslogtreecommitdiff
path: root/tests/micropython
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-07-09 00:05:59 +1000
committerDamien George <damien@micropython.org>2022-07-12 17:18:27 +1000
commit9714a0ead5c74649d676986836ee27fb418aac9e (patch)
tree5465ae77dfe68ecdb3e7232fad11d41b86d5ea76 /tests/micropython
parente1282556e82ed470941a845af447065502a2c5ad (diff)
py/emitnative: Fix STORE_ATTR viper code-gen when value is not a pyobj.
There was a missing call to MP_F_CONVERT_NATIVE_TO_OBJ. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tests/micropython')
-rw-r--r--tests/micropython/viper_storeattr.py25
-rw-r--r--tests/micropython/viper_storeattr.py.exp4
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/micropython/viper_storeattr.py b/tests/micropython/viper_storeattr.py
new file mode 100644
index 000000000..65f68b6e2
--- /dev/null
+++ b/tests/micropython/viper_storeattr.py
@@ -0,0 +1,25 @@
+# test storing an attribute with a value of different viper types
+
+
+class X:
+ def __str__(self):
+ return "X"
+
+
+x = X()
+
+
+@micropython.viper
+def a():
+ x.i0 = 0
+ x.i7 = 7
+ x.s = "hello"
+ x.o = x
+
+
+a()
+
+print(x.i0)
+print(x.i7)
+print(x.s)
+print(x.o)
diff --git a/tests/micropython/viper_storeattr.py.exp b/tests/micropython/viper_storeattr.py.exp
new file mode 100644
index 000000000..8e6a6cfda
--- /dev/null
+++ b/tests/micropython/viper_storeattr.py.exp
@@ -0,0 +1,4 @@
+0
+7
+hello
+X