Adafruit_CircuitPython_PIOASM/tests/test_mov.py
KB Sriram 3e6a8bc392 Add type annotations for library and tests.
Verified that `mypy --strict adafruit_pioasm.py tests` runs without
errors.

Fixes: https://github.com/adafruit/Adafruit_CircuitPython_PIOASM/issues/24
2024-05-27 12:30:52 -07:00

29 lines
820 B
Python

# SPDX-FileCopyrightText: 2021 Jeff Epler, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Tests mov
"""
from pytest_helpers import assert_assembles_to, assert_assembly_fails
def test_mov_non_happy() -> None:
# non happy path
assert_assembly_fails(
"mov x, blah", match="Invalid mov source 'blah'", errtype=ValueError
)
def test_mov_invert() -> None:
# test moving and inverting
assert_assembles_to("mov x, ~ x", [0b101_00000_001_01_001])
assert_assembles_to("mov x, ~x", [0b101_00000_001_01_001])
assert_assembles_to("mov x, !x", [0b101_00000_001_01_001])
def test_mov_reverse() -> None:
# test moving and reversing bits
assert_assembles_to("mov x, :: x", [0b101_00000_001_10_001])
assert_assembles_to("mov x, ::x", [0b101_00000_001_10_001])