diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/micropython/viper_subscr.py | 20 | ||||
| -rw-r--r-- | tests/micropython/viper_subscr.py.exp | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/micropython/viper_subscr.py b/tests/micropython/viper_subscr.py new file mode 100644 index 000000000..2198ed731 --- /dev/null +++ b/tests/micropython/viper_subscr.py @@ -0,0 +1,20 @@ +# test standard Python subscr using viper types + +@micropython.viper +def get(dest, i:int): + i += 1 + return dest[i] + +@micropython.viper +def set(dest, i:int, val:int): + i += 1 + dest[i] = val + 1 + +ar = [i for i in range(3)] + +for i in range(len(ar)): + set(ar, i - 1, i) +print(ar) + +for i in range(len(ar)): + print(get(ar, i - 1)) diff --git a/tests/micropython/viper_subscr.py.exp b/tests/micropython/viper_subscr.py.exp new file mode 100644 index 000000000..e68032ce1 --- /dev/null +++ b/tests/micropython/viper_subscr.py.exp @@ -0,0 +1,4 @@ +[1, 2, 3] +1 +2 +3 |
