tests: Add test for machine module (mem* functions).
This commit is contained in:
parent
76abb2e623
commit
0589c19d52
33
tests/extmod/machine1.py
Normal file
33
tests/extmod/machine1.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# test machine module
|
||||||
|
|
||||||
|
import machine
|
||||||
|
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")
|
7
tests/extmod/machine1.py.exp
Normal file
7
tests/extmod/machine1.py.exp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<8-bit memory>
|
||||||
|
123
|
||||||
|
12345
|
||||||
|
123456789
|
||||||
|
ValueError
|
||||||
|
ValueError
|
||||||
|
TypeError
|
Loading…
Reference in New Issue
Block a user