3dc324d3f1
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
42 lines
543 B
Python
42 lines
543 B
Python
# test ptr8 type
|
|
|
|
|
|
@micropython.viper
|
|
def set(dest: ptr8, val: int):
|
|
dest[0] = val
|
|
|
|
|
|
@micropython.viper
|
|
def set1(dest: ptr8, val: int):
|
|
dest[1] = val
|
|
|
|
|
|
@micropython.viper
|
|
def memset(dest: ptr8, val: int, n: int):
|
|
for i in range(n):
|
|
dest[i] = val
|
|
|
|
|
|
@micropython.viper
|
|
def memset2(dest_in, val: int):
|
|
dest = ptr8(dest_in)
|
|
n = int(len(dest_in))
|
|
for i in range(n):
|
|
dest[i] = val
|
|
|
|
|
|
b = bytearray(4)
|
|
print(b)
|
|
|
|
set(b, 41)
|
|
print(b)
|
|
|
|
set1(b, 42)
|
|
print(b)
|
|
|
|
memset(b, 43, len(b))
|
|
print(b)
|
|
|
|
memset2(b, 44)
|
|
print(b)
|