From 0589c19d5239bb4456f06049925d71851e896d1e Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 8 May 2015 00:18:28 +0100 Subject: [PATCH] tests: Add test for machine module (mem* functions). --- tests/extmod/machine1.py | 33 +++++++++++++++++++++++++++++++++ tests/extmod/machine1.py.exp | 7 +++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/extmod/machine1.py create mode 100644 tests/extmod/machine1.py.exp diff --git a/tests/extmod/machine1.py b/tests/extmod/machine1.py new file mode 100644 index 0000000000..f93f79b284 --- /dev/null +++ b/tests/extmod/machine1.py @@ -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") diff --git a/tests/extmod/machine1.py.exp b/tests/extmod/machine1.py.exp new file mode 100644 index 0000000000..e46afc7528 --- /dev/null +++ b/tests/extmod/machine1.py.exp @@ -0,0 +1,7 @@ +<8-bit memory> +123 +12345 +123456789 +ValueError +ValueError +TypeError