summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/machine1.py
blob: e7fd40d4dbd2f969741d5284a3858484eac38bb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# test machine module

try:
    import machine
except ImportError:
    print("SKIP")
    import sys
    sys.exit()

import uctypes

print(machine.mem8)

buf = bytearray(8)
addr = uctypes.addressof(buf)

machine.mem8[addr] = 123
print(machine.mem8[addr])

machine.mem16[addr] = 12345
print(machine.mem16[addr])

machine.mem32[addr] = 123456789
print(machine.mem32[addr])

try:
    machine.mem16[1]
except ValueError:
    print("ValueError")

try:
    machine.mem16[1] = 1
except ValueError:
    print("ValueError")

try:
    del machine.mem8[0]
except TypeError:
    print("TypeError")